package com.hybrid.jsbridge;

import android.content.Context;
import android.content.Intent;
import com.hybrid.webview.WVWebView;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-10-09 22:24
 * @version: 9.1.0
 */
public abstract class WVApiPlugin {
    public static final int REQUEST_TAKE_PHOTO = 4001;
    public static final int REQUEST_PICK_PHOTO = REQUEST_TAKE_PHOTO + 1;
    public static final int REQUEST_PICK_PHONE = REQUEST_PICK_PHOTO + 1;
    public static final int REQUEST_MULTI_PICK_PHOTO = REQUEST_PICK_PHOTO + 1;

    protected Context mContext;
    protected WVWebView mWebView;
    protected Object paramObj;
    protected boolean isAlive = true;

    public WVApiPlugin() {
    }

    public void initialize(Context context, WVWebView webView) {
        initialize(context,webView,null);
    }

    public void initialize(Context context, WVWebView webView,Object paramObj ) {
        this.mContext = context;
        this.mWebView = webView;
        this.paramObj=paramObj;
    }

    /**
     * 统一的执行入口
     *
     * @param action
     *            执行动作名称，原有的method名称
     * @param params
     *            传参
     * @param callback
     *            回调上下文
     * @return true:对应action存在
     */
    public abstract boolean execute(String action, String params, WVCallBackContext callback);

    public void onDestroy() {
        isAlive = false;
    }

    public void onPause() {
        isAlive = false;
    }

    public void onResume() {
        isAlive = true;
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    }

    public void onScrollChanged(int l, int t, int oldl, int oldt) {
    }
}
